/**
 * Created by 魏爷 on 2016/5/29.
 */
$(function(){
    var url=$('#book_url').val();
    var borrow_url=$('#BorrowID').val();
    var app={
        borrow:function(obj){
            var loading=layer.load(1);
            $.post(
                url,
                {book_id:obj.attr('data-id-book')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },

        courst:function(obj){
            var loading=layer.load(1);
            $.post(
                borrow_url,
                {borrow_id:obj.attr('date-id-read')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },

    }
    $('.bor').click(function () {
        app.borrow($(this));
    });
    $('.courst').click(function () {
        app.courst($(this));
    });
});

